home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / gdb-4.5 / dist / gdb / symfile.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-03-29  |  7.1 KB  |  225 lines

  1. /* Definitions for reading symbol files into GDB.
  2.    Copyright (C) 1990, 1991, 1992  Free Software Foundation, Inc.
  3.  
  4. This file is part of GDB.
  5.  
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10.  
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with this program; if not, write to the Free Software
  18. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. #if !defined (SYMFILE_H)
  21. #define SYMFILE_H
  22.  
  23. /* This file requires that you first include "bfd.h".  */
  24.  
  25. struct psymbol_allocation_list {
  26.   struct partial_symbol *list;
  27.   struct partial_symbol *next;
  28.   int size;
  29. };
  30.  
  31. /* Structure to keep track of symbol reading functions for various
  32.    object file types.  */
  33.  
  34. struct sym_fns {
  35.  
  36.   /* is the name, or name prefix, of the BFD "target type" that this
  37.      set of functions handles.  E.g. "a.out" or "sunOs" or "coff" or "elf".  */
  38.  
  39.   char *sym_name;
  40.  
  41.   /* counts how many bytes of sym_name should be checked against the
  42.      BFD target type of the file being read.  If an exact match is
  43.      desired, specify the number of characters in sym_name plus 1 for the
  44.      NUL.  If a prefix match is desired, specify the number of characters in
  45.      sym_name.  */
  46.  
  47.   int sym_namelen;
  48.  
  49.   /* Initializes anything that is global to the entire symbol table.  It is
  50.      called during symbol_file_add, when we begin debugging an entirely new
  51.      program. */
  52.  
  53.   void (*sym_new_init) PARAMS ((struct objfile *));
  54.  
  55.   /* Reads any initial information from a symbol file, and initializes the
  56.      struct sym_fns SF in preparation for sym_read().  It is called every
  57.      time we read a symbol file for any reason. */
  58.  
  59.   void (*sym_init) PARAMS ((struct objfile *));
  60.  
  61.   /* sym_read (objfile, addr, mainline)
  62.      Reads a symbol file into a psymtab (or possibly a symtab).
  63.      OBJFILE is the objfile struct for the file we are reading.  ADDR
  64.      is the offset between the file's specified start address and
  65.      its true address in memory.  MAINLINE is 1 if this is the
  66.      main symbol table being read, and 0 if a secondary
  67.      symbol file (e.g. shared library or dynamically loaded file)
  68.      is being read.  */
  69.  
  70.   void (*sym_read) PARAMS ((struct objfile *, CORE_ADDR, int));
  71.  
  72.   /* Called when we are finished with an objfile.  Should do all cleanup
  73.      that is specific to the object file format for the particular objfile. */
  74.  
  75.   void (*sym_finish) PARAMS ((struct objfile *));
  76.  
  77.   /* Finds the next struct sym_fns.  They are allocated and initialized
  78.      in whatever module implements the functions pointed to; an 
  79.      initializer calls add_symtab_fns to add them to the global chain.  */
  80.  
  81.   struct sym_fns *next;
  82.  
  83. };
  84.  
  85. extern void
  86. extend_psymbol_list PARAMS ((struct psymbol_allocation_list *,
  87.                  struct objfile *));
  88.  
  89. /* Add any kind of symbol to a psymbol_allocation_list. */
  90.  
  91. #define    ADD_PSYMBOL_VT_TO_LIST(NAME,NAMELENGTH,NAMESPACE,CLASS,LIST,VALUE,VT) \
  92.   do {                                        \
  93.     register struct partial_symbol *psym;                \
  94.     if ((LIST).next >= (LIST).list + (LIST).size)            \
  95.        extend_psymbol_list (&(LIST),objfile);                \
  96.     psym = (LIST).next++;                        \
  97.                                     \
  98.     SYMBOL_NAME (psym) = (char *) obstack_alloc (&objfile->psymbol_obstack,    \
  99.                          (NAMELENGTH) + 1);    \
  100.     memcpy (SYMBOL_NAME (psym), (NAME), (NAMELENGTH));            \
  101.     SYMBOL_NAME (psym)[(NAMELENGTH)] = '\0';                \
  102.     SYMBOL_NAMESPACE (psym) = (NAMESPACE);                \
  103.     SYMBOL_CLASS (psym) = (CLASS);                    \
  104.     VT (psym) = (VALUE);                         \
  105.   } while (0);
  106.  
  107. #ifdef DEBUG
  108.  
  109. /* Since one arg is a struct, we have to pass in a ptr and deref it (sigh) */
  110.  
  111. #define    ADD_PSYMBOL_TO_LIST(name, namelength, namespace, class, list, value) \
  112.   add_psymbol_to_list (name, namelength, namespace, class, &list, value)
  113.  
  114. #define    ADD_PSYMBOL_ADDR_TO_LIST(name, namelength, namespace, class, list, value) \
  115.   add_psymbol_addr_to_list (name, namelength, namespace, class, &list, value)
  116.  
  117. #else    /* !DEBUG */
  118.  
  119. /* Add a symbol with an integer value to a psymtab. */
  120.  
  121. #define ADD_PSYMBOL_TO_LIST(name, namelength, namespace, class, list, value) \
  122.   ADD_PSYMBOL_VT_TO_LIST (name, namelength, namespace, class, list, value, SYMBOL_VALUE)
  123.  
  124. /* Add a symbol with a CORE_ADDR value to a psymtab. */
  125.  
  126. #define    ADD_PSYMBOL_ADDR_TO_LIST(name, namelength, namespace, class, list, value)\
  127.   ADD_PSYMBOL_VT_TO_LIST (name, namelength, namespace, class, list, value, SYMBOL_VALUE_ADDRESS)
  128.  
  129. #endif    /* DEBUG */
  130.  
  131.             /*   Functions   */
  132.  
  133. extern void
  134. sort_pst_symbols PARAMS ((struct partial_symtab *));
  135.  
  136. extern struct symtab *
  137. allocate_symtab PARAMS ((char *, struct objfile *));
  138.  
  139. extern int
  140. free_named_symtabs PARAMS ((char *));
  141.  
  142. extern void
  143. fill_in_vptr_fieldno PARAMS ((struct type *));
  144.  
  145. extern void
  146. add_symtab_fns PARAMS ((struct sym_fns *));
  147.  
  148. extern void
  149. init_entry_point_info PARAMS ((struct objfile *));
  150.  
  151. extern void
  152. syms_from_objfile PARAMS ((struct objfile *, CORE_ADDR, int, int));
  153.  
  154. extern struct partial_symtab *
  155. start_psymtab_common PARAMS ((struct objfile *, CORE_ADDR, char *, CORE_ADDR,
  156.                   struct partial_symbol *,
  157.                   struct partial_symbol *));
  158.  
  159. /* Sorting your symbols for fast lookup or alphabetical printing.  */
  160.  
  161. extern void
  162. sort_block_syms PARAMS ((struct block *));
  163.  
  164. extern void
  165. sort_symtab_syms PARAMS ((struct symtab *));
  166.  
  167. extern void
  168. sort_all_symtab_syms PARAMS ((void));
  169.  
  170. /* Make a copy of the string at PTR with SIZE characters in the symbol obstack
  171.    (and add a null character at the end in the copy).
  172.    Returns the address of the copy.  */
  173.  
  174. extern char *
  175. obsavestring PARAMS ((char *, int, struct obstack *));
  176.  
  177. /* Concatenate strings S1, S2 and S3; return the new string.
  178.    Space is found in the symbol_obstack.  */
  179.  
  180. extern char *
  181. obconcat PARAMS ((struct obstack *obstackp, const char *, const char *,
  182.           const char *));
  183.  
  184.             /*   Variables   */
  185.  
  186. /* Support for complaining about things in the symbol file that aren't
  187.    catastrophic.
  188.  
  189.    Each such thing gets a counter.  The first time we have the problem,
  190.    during a symbol read, we report it.  At the end of symbol reading,
  191.    if verbose, we report how many of each problem we had.  */
  192.  
  193. struct complaint {
  194.   char *message;
  195.   unsigned counter;
  196.   struct complaint *next;
  197. };
  198.  
  199. /* Root of the chain of complaints that have at some point been issued. 
  200.    This is used to reset the counters, and/or report the total counts.  */
  201.  
  202. extern struct complaint complaint_root[1];
  203.  
  204. /* Functions that handle complaints.  (in symfile.c)  */
  205.  
  206. extern void
  207. complain PARAMS ((struct complaint *, char *));
  208.  
  209. extern void
  210. clear_complaints PARAMS ((int sym_reading, int noisy));
  211.  
  212. /* From symfile.c */
  213.  
  214. extern struct partial_symtab *
  215. allocate_psymtab PARAMS ((char *, struct objfile *));
  216.  
  217. /* From dwarfread.c */
  218.  
  219. extern void
  220. dwarf_build_psymtabs PARAMS ((int, char *, CORE_ADDR, int, unsigned int,
  221.                   unsigned int, unsigned int, unsigned int,
  222.                   struct objfile *));
  223.  
  224. #endif    /* !defined(SYMFILE_H) */
  225.